<?php

namespace App\Console\Commands;

use App\Models\CarryApplyLogModel;
use App\Services\MemberService;
use App\Utils\WxUtil;
use Illuminate\Console\Command;

/**
 * Class SyncPddOrders
 * @package App\Console\Commands
 * 提现申请，一分钟一次
 */
class CrontabCarryApply extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'cron:CarryApply';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '提现任务处理';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {

        $carryApplyLog = new CarryApplyLogModel();
        $applyInfo = $carryApplyLog->where([
            'apply' => 1
        ])->first();
        if($applyInfo){
            $memberService = new MemberService();
            $memberInfo = $memberService->getMemberInfoById($applyInfo->user_id);
            // 实例化服务层
            $serviceTransfer = new WxUtil();
            // 带参请求：sOpenid（收款方openid）   nMoney（转账金额）
            $result = $serviceTransfer->transfer_batches($memberInfo->openid, $applyInfo->money);
            dd($result);
        }
    }
}
